<%
controller ||= params[:controller]
url_params = {:controller => controller, :action => :select}

pagination_url_params = params.merge(:controller => controller, :action => :browse, :search => params[:search], :update => 1)
prev_url = url_for(pagination_url_params.merge(:page => page.prev.number, :escape => false)) if page.prev?
next_url = url_for(pagination_url_params.merge(:page => page.next.number, :escape => false)) if page.next?
-%>
<ol>
  <li class="found"><%= page.pager.count %> <%= record_select_config.model.to_s.pluralize.titleize.downcase %> found</li>
  <% if page.prev? -%>
  <li class="pagination previous">
    <%= link_to_remote image_tag('record_select/previous.gif', :alt => 'Previous') + " Previous #{page.pager.per_page}",
                      {:url => prev_url, :method => :get},
                      {:href => prev_url} %>
  </li>
  <% end -%>
  <% page.items.each do |record| -%>
  <li class="record <%= cycle 'odd', 'even' %>" id="rs<%= record.id -%>">
    <% url = url_for(url_params.merge(:id => record.id, :escape => false)) -%>
    <%= link_to_remote h(record_select_config.label.call(record)),
                        {:url => url,
                        :method => :post,
                        :before => 'Element.toggleClassName(this, "selected")',
                        :condition => "RecordSelect.notify(this)"},
                        {:href => url} %>
  </li>
  <% end -%>
  <% if page.next? -%>
  <li class="pagination next">
    <%= link_to_remote "Next #{page.pager.per_page} " + image_tag('record_select/next.gif', :alt => 'Next'),
                        {:url => next_url, :method => :get},
                        {:href => next_url} %>
  </li>
  <% end -%>
</ol>